﻿(function () {
    new Vue({
        el: '#news-detail',
        components: {
            'clinic-head': clinicHead,
            'clinic-foot': clinicFoot,
        },
        data: {
            pageInfo: {
                curPageRecord: [],
                keyWord: "",
                totalCount: "",
                pageSize: 9,
                pageCount: 10,
                pageCurrent: 1,
                ImgUrl: "",
                categoryType: ""
            },
            detailInfo: { title: '', add_time: '', content: '', videoSrc :''},
            articlesList: [],
            userName: '',
            loginInfo: { isLogin: '', name: '', mobile: '' },
            navigationBar: [],
            showVideo: true
        },
        created: function () {
            var _self = this;
            console.log(_self.tab);
            //检查登录状态
            CheckLoginStatus(_self, _self.loginInfo);
        },
        mounted: function () {
            showHtml();
            var _self = this;
            //设置导航栏样式
            document.getElementById("Home").className = "invalid-nav";
            document.getElementById("OrderExpert").className = "invalid-nav";
            document.getElementById("DistinctMedical").className = "invalid-nav";
            document.getElementById("MedicalWiki").className = "invalid-nav";
            document.getElementById("News").className = "invalid-nav";
            document.getElementById("AboutUs").className = "invalid-nav";

            window.scrollBy(0, -100);
            var p_id = getQueryString("Id");
            var p_type = getQueryString("Type");
            var p_tabId = getQueryString("TabId");
            var p_showVideo = getQueryString("ShowVideo");

            if (p_id != null) {
                _self.GetArticleDetial(p_id);
                if (p_showVideo === "false")
                    _self.showVideo = false;
                //_self.getCurTabNavBar(p_type, p_tabId);
                //_self.showNevigationBar(_self.navigationBar);
            }

        },
        methods: {
            GetArticleDetial: function (p_id) {
                var _self = this;
                var detailContent = document.getElementById("detailContent");
                _self.pageInfo.keyWord = p_id;
                _self.curPath = "/NewsDetail/GetArticleDetial";
                _self.$http.post("/NewsDetail/GetArticleDetial", _self.pageInfo).then(function (res) {
                    if (res.body.Code === -1) {
                        noResult.style.display = "block";
                    }
                    else {
                        _self.detailInfo.title = res.body.title;
                        _self.detailInfo.add_time = res.body.add_time;
                        detailContent.innerHTML = res.body.content;
                        _self.detailInfo.videoSrc = res.body.videoSrc;
                    }
                });
            },
            showNevigationBar: function (p_navigation) {
                var _self = this;
                var navContent;
                var navBar = document.getElementById("navigation-bar");
                if (p_navigation != null) {
                    _self.nevigation = p_navigation;
                    if (_self.nevigation.length > 0) {
                        for (index = 0; index < _self.nevigation.length; index++) {
                            if (index === 0)
                                navContent = '<a href="' + _self.nevigation[index].url + '">' + _self.nevigation[index].name + '</a>';
                            else
                                navContent = navContent + ' > ' + '<a href="' + _self.nevigation[index].url + '">' + _self.nevigation[index].name + '</a>';
                        }
                        navContent = navContent + ' > 正文';
                        navBar.innerHTML = navContent;
                    }
                }
            },
            getCurTabNavBar: function (p_tabId, p_type) {
                var _self = this;
                if (p_type === "wiki") {
                    if (p_tabId === "1")
                        _self.navigationBar = [{ name: '医学百科', url: '/MedicalWiki/Index' }, { name: '专家说病', url: '/MedicalWiki/Index?tabId=1' }];
                    else if (p_tabId === "2")
                        _self.navigationBar = [{ name: '医学百科', url: '/MedicalWiki/Index' }, { name: '疾病大全', url: '/MedicalWiki/Index?tabId=2' }];
                    else if (p_tabId === "3")
                        _self.navigationBar = [{ name: '医学百科', url: '/MedicalWiki/Index' }, { name: '病案分享', url: '/MedicalWiki/Index?tabId=3' }];
                }
                else {
                    if (p_tabId === "1")
                        _self.navigationBar = [{ name: '最新动态', url: '/News/Index' }, { name: '全部', url: '/News/Index?tabId=1' }];
                    else if (p_tabId === "2")
                        _self.navigationBar = [{ name: '最新动态', url: '/News/Index' }, { name: '诊所公告', url: '/News/Index?tabId=2' }];
                    else if (p_tabId === "3")
                        _self.navigationBar = [{ name: '最新动态', url: '/News/Index' }, { name: '诊所动态', url: '/News/Index?tabId=3' }];
                }
            }
        }
    })
})();